import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
    // in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading

/* layout */
import Layout from '../views/layout/Layout';
import Dashboard from '../views/dashboard/index';
import Chart from '../views/chart/index';
import Park from '../views/Pages/WisdomPark';

const Login = _import('login/login');

Vue.use(Router)

/**
 * icon : the icon show in the sidebar
 * hidden : if `hidden:true` will not show in the sidebar
 * redirect : if `redirect:noredirect` will not redirct in the levelbar
 * noDropdown : if `noDropdown:true` will not has submenu in the sidebar
 * meta : `{ role: ['admin'] }`  will control the page role
 **/
export const constantRouterMap = [
    // {
    //   path: '/login',
    //   name: 'login',
    //   meta: {
    //     title: 'Login - 登录'
    //   },
    //   hidden: true,
    //   component: resolve => {
    //     require(['../views/login/login.vue'], resolve);
    //   }
    // },
    {
        path: '/',
        component: Dashboard,
        redirect: '/dashboard',
        name: 'Dashboard',
        hidden: true,
        children: [{ path: 'dashboard', title: 'home', name: 'home_index', component: _import('dashboard/index') }]
    }
];


export const otherRouterMap = [{
        path: '/data_search_download',
        icon: 'md-arrow-down',
        name: 'data_search_download',
        title: '数据搜索下载',
        component: Layout,
        redirect: '/test/index',
        children: [{ path: 'index', icon: 'md-arrow-down', title: '数据搜索下载', name: 'dataSD', component: _import('components/DataSearchDownload') }]
    },
    {
        path: '/media_resources',
        icon: 'ios-keypad',
        name: 'media',
        title: '媒体资源上传',
        component: Layout,
        redirect: '/media_resources/index',
        children: [{ path: 'index', icon: 'ios-keypad', title: '媒体资源上传', name: 'media', component: _import('components/MediaResources') }]
    },
    {
        path: '/enterprise_library',
        icon: 'ios-analytics',
        name: 'library',
        title: '企业库',
        component: Layout,
        redirect: '/media_resources/index',
        children: [{ path: 'index', icon: 'ios-analytics', title: '企业库', name: 'enterprise', component: _import('components/EnterpriseLibrary') }]
    },
    {
        path: '/policy_library',
        icon: 'md-desktop',
        name: 'policy',
        title: '政策库',
        component: Layout,
        redirect: '/policy_library/index',
        children: [{
                path: 'index',
                title: '政策跟踪',
                name: 'PolicyLibrary',
                component: _import('components/PolicyLibrary'),
                redirect: '/policy_library/index/last',
                children: [{
                    path: 'last',
                    title: '最新政策',
                    name: 'PolicyLibrary',
                    component: _import('components/PolicyLibraryLast')
                }, {
                    path: 'news',
                    title: '科技政策动态',
                    name: 'PolicyLibrary',
                    component: _import('components/PolicyLibraryNews')
                }, {
                    path: 'reading',
                    title: '科技政策解读',
                    name: 'PolicyLibrary',
                    component: _import('components/PolicyLibraryReading')
                }, {
                    path: 'analysis',
                    title: '科技政策解读',
                    name: 'PolicyLibrary',
                    component: _import('components/PolicyLibraryAnalysis')
                }, {
                    path: 'detail/type/:type/id/:id',
                    title: '政策详情',
                    name: 'PolicyLibrary',
                    component: _import('components/PolicyLibraryDetail')
                }, {
                    path: 'manage',
                    title: '我的跟踪管理',
                    name: 'PolicyLibrary',
                    component: _import('components/PolicyLibraryManage')
                }]
            },
            {
                path: 'declare',
                title: '申报跟踪',
                name: 'PolicyDeclare',
                component: _import('components/PolicyDeclare'),
                redirect: '/policy_library/declare/last',
                children: [{
                    path: 'last',
                    title: '最新申报信息',
                    name: 'PolicyDeclare',
                    component: _import('components/PolicyDeclareLast')
                }, {
                    path: 'detail/type/:type/id/:id',
                    title: '申报信息详情',
                    name: 'PolicyDeclare',
                    component: _import('components/PolicyDeclareDetail')
                }, {
                    path: 'manage',
                    title: '我的跟踪',
                    name: 'PolicyDeclare',
                    component: _import('components/PolicyDeclareManage')
                }]
            }
        ]
    },
    {
        path: '/chart',
        icon: 'ios-archive',
        name: 'Chart',
        title: '数字大屏',
        component: Chart,
        redirect: '/chart/index',
        children: [{
            path: 'index',
            icon: 'md-bookmarks',
            title: '数字大屏',
            name: 'Chart',
            component: _import('chart/index')
        }]
    },
    {
        path: '/park',
        icon: '',
        name: 'Park',
        title: '智慧园区',
        hidden: true,
        component: Layout,
        redirect: '/park/index',
        children: [{
            path: 'index',
            icon: '',
            title: '智慧园区',
            name: 'Park',
            component: _import('Pages/WisdomPark')
        }]
    }
];

export default new Router({
    mode: 'history', //后端支持可开
    base: '/tcsamp/',
    scrollBehavior: () => ({ y: 0 }),
    routes: [
        ...constantRouterMap,
        ...otherRouterMap
    ]
})